home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 240 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: steven2@salesbk.com
  3. Newsgroups: comp.std.c++
  4. Subject: Re: typeinfo
  5. Date: 2 Feb 1996 15:49:01 GMT
  6. Organization: DownEast Technology Inc.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4es3ur$4ha@post.acadia.net>
  9. References: <310B7660.4116@suphys.physics.su.oz.au>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. Content-Type: text
  12. X-Nntp-Posting-Host: blf6.acadia.net
  13. X-Newsreader: Forte Free Agent 1.0.82
  14. Content-Length: 534
  15. X-Lines: 24
  16. Originator: clamage@taumet
  17.  
  18. John Max Skaller <maxtal@suphys.physics.su.oz.au> wrote:
  19.  
  20. >> class beatha{public:virtual ~beatha(){};}
  21. >> class duine:public beatha{};
  22. >> class gael: public duine {};
  23. >> 
  24. >> beatha *pd=new gael;
  25. >> if(typeid(pd)==typeid(duine)
  26. >> {       cout<<"duine";
  27. >> }
  28. >> ...
  29. >> does "duine" get printed here or not?
  30.  
  31. >No. pd denotes an object of exact type "gael".
  32.  
  33. I believe typeid (pd) is typeid (betha*). What I think you wanted is
  34.  
  35. if (typeid (*pd) == typeid (duine))
  36.  
  37. and so (typeid (*pd) == typeid (gael)) will evaluate to true.
  38.  
  39. Steve
  40.  
  41.  
  42.  
  43. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  44.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  45.   summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  46. ]
  47.